<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let sendAjax = (url) => {
            return new Promise((resolve, reject) => {
                const x = new XMLHttpRequest();
                x.open('GET', url);
                x.send();
                x.onreadystatechange = () => {
                    if (x.readyState === 4 && x.status === 400) {
                        resolve(x.response);
                    } else {
                        reject(x.status);
                    }
                }
            })
        }

        async function main(){
            await sendAjax('https://api.apiopen.top/getJoke');
            console.log(result);
        }
        main()
    </script>
</body>

</html>